﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;

namespace Quản_Lý_Thư_Viện
{
    class ctpnsDataAccess
    {
        private DataProvider _provider = new DataProvider();
        public ctpnsDataAccess()
        {
            _provider.connect();
        }
        public void insertctpns(PhieunhapsachInfo info)
        {
            string insertCommand = "insert into dbo.CT_PNS(MAPNS,MADAUSACH,SOLUONG) values('"+info.Mapns+"','"+info.Madausach+"','"+info.Soluong+"')";
            _provider.executeNonQuery(insertCommand);
        }
        public void deletectpns(PhieunhapsachInfo info)
        {
            string deleteCommand = "Delete from dbo.CT_PNS where MADAUSACH = '" + info.Madausach + "'";
            _provider.executeNonQuery(deleteCommand);
        }
        public void deletectpns2(PhieunhapsachInfo info)
        {
            string deleteCommand = "Delete from dbo.CT_PNS where MAPNS = '" + info.Mapns + "'";
            _provider.executeNonQuery(deleteCommand);
        }
        public DataTable top4sachmoi()
        {
            return _provider.GetData("select top 4 dbo.CT_PNS.MADAUSACH, HINHANH from dbo.CT_PNS, dbo.DAUSACH where dbo.DAUSACH.MADAUSACH = dbo.CT_PNS.MADAUSACH and MAPNS in ( select TOP 4 MAPNS from dbo.PHIEUNHAPSACH order by NGNHAP desc)");
        }
    }
}
